package com.zhl.hadoop.mapreduce.sort;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @program: demos
 * @description: 自己的类型序列化不适用java自带的序列化
 * @author: 刘振华
 * @create: 2020-10-28 10:57
 **/
public class SortMapper extends Mapper<LongWritable, Text,SortBean, NullWritable> {

	@Override
	protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
		String[] line = value.toString().split("\t");
		SortBean bean = new SortBean();
		bean.setName(line[0]);
		bean.setScore(Integer.parseInt(line[1]));
		context.write(bean,NullWritable.get());
	}
}
